package com.eugene.ui.views.property;

import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.ui.views.properties.TextPropertyDescriptor;

import com.eugene.entity.Scenario;

public class ScenarioProp implements IPropertySource{
	
	private Scenario sce;
//	private Boolean flag;
	
	public ScenarioProp() {
	}
	public ScenarioProp(Scenario sce) {
		this.sce =sce;
	}

	@Override
	public Object getEditableValue() {
//		return this;
		return sce;
	}
	
	@Override
	public IPropertyDescriptor[] getPropertyDescriptors() {
		TextPropertyDescriptor sceSetDesc = new TextPropertyDescriptor(sce.getSceSetId(), "01.SceSetId");
//		ComboBoxPropertyDescriptor sceDesc = new ComboBoxPropertyDescriptor(sce.getSceId(), "02.SceId", new String[]{"AAA","BBB"});
		TextPropertyDescriptor sceDesc = new TextPropertyDescriptor(sce.getSceId(), "02.SceId");
		TextPropertyDescriptor mvDesc = new TextPropertyDescriptor(sce.getMarketVari(), "03.MarketVariable");
		PropertyDescriptor coefficientDesc = new PropertyDescriptor(sce.getCoefficient(), "04.Coefficient");

//		Grouping Property
		sceSetDesc.setCategory("Label");
		sceDesc.setCategory("Label");
		
		
		IPropertyDescriptor[] propDesc = new IPropertyDescriptor[] {
				sceSetDesc,sceDesc, 
				mvDesc, 
				coefficientDesc
				};
		
		return propDesc;

	}
	
	@Override
	public Object getPropertyValue(Object property) {
		if (sce.getSceSetId().equals(property)) return sce.getSceSetId();
		else if (sce.getSceId().equals(property)) return sce.getSceId();
		else if (sce.getMarketVari().equals(property)) return sce.getMarketVari();
		else if (((Double)sce.getCoefficient()).equals(property)) return sce.getCoefficient();

		return null;
	}
	
	@Override
	public void setPropertyValue(Object id, Object value) {
		if (sce.getSceSetId().equals(id)) {
			sce.setSceSetId((String)value);
		}
//		else if (sce.getSceId().equals(id)) sce.setSceId((String)value);
//		else if (sce.getMarketVari().equals(id)) sce.getMarketVari((String)value);
	}
	
	@Override
	public boolean isPropertySet(Object id) {
		return false;
	}
	
	@Override
	public void resetPropertyValue(Object id) {
//		if(flag){
//			setPropertyValue(id,"aaa");
//		}
	}


}
